home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / appl / napsaterm / nifty.h < prev    next >
C/C++ Source or Header  |  1994-05-14  |  5KB  |  143 lines

  1. /* $Id: nifty.h,v 3.3 1994/05/14 12:37:26 ppessi Exp $
  2.  *
  3.  * nifty.h -- useful macros, etc.
  4.  *
  5.  * Authors: Chris Newman, ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  8.  *                    Helsinki University of Technology, Finland.
  9.  *                    All rights reserved.
  10.  *
  11.  * See file COPYING for conditions to copy, modify and use this program.
  12.  *
  13.  * Copyright 1988, Chris Newman
  14.  * All Rights Reserved
  15.  * Permission is granted to copy, modify, and use this as long
  16.  * as this notice remains intact.  This is a nifty program.
  17.  *
  18.  * Some of these #defines were swiped from various places
  19.  *
  20.  * DISCLAIMER: the author (and maintainer) of this program is not responsible
  21.  * for any damage or other problems caused by it.
  22.  */
  23.  
  24. #ifndef NIFTY_H
  25. #define NIFTY_H
  26.  
  27. #define PROGNAME "Napsaterm"
  28.  
  29. extern const char ProgName[];
  30.  
  31. #ifndef NAPSA_CONFIG_H
  32. #include "config.h"
  33. #endif
  34.  
  35. /* types */
  36. #define    Boolean int
  37. typedef    char    BOOLEAN;
  38. typedef    unsigned short ushort;
  39. typedef    unsigned char  uchar;
  40.  
  41. /* constants */
  42. #undef CTRL
  43. #define CTRL(a) ((a) & 0x1f)
  44. #define CTRL8(a) ((a) & 0x1f | 0x80)
  45. #define    ESC    '\033'
  46. #define    DEL    '\177'
  47.  
  48. /* bound and limit macros */
  49. #define    SLIMIT(a, b)        ((a) >= (b) ? ((a) = (b) - 1) : (a))
  50. #define    SLIMITCK(a, b)        if ((a) >= (b)) (a) = (b) - 1
  51. #define    MAXBOUND(a, b)        ((a) > (b) ? (a) = (b): (a))
  52. #define    MAXBOUNDCK(a, b)    if ((a) > (b)) (a) = (b)
  53. #define    MINBOUND(a, b)        ((a) < (b) ? (a) = (b): (a))
  54. #define    MINBOUNDCK(a, b)    if ((a) < (b)) (a) = (b)
  55. #define    BOUNDS(a, l, h)        ((a) < (l) ? (a) = (l) : ((a) > (h) ? (a) = (h) : (a)))
  56. #define    BOUNDSCK(a, l, h)   if ((a) < (l)) (a) = (l); else if ((a) > (h)) (a) = (h)
  57.  
  58. /* useful macros */
  59. #undef ABS
  60. #undef MIN
  61. #undef MAX
  62. #define    ABS(a)        ((a) < 0 ? -(a) : (a))
  63. #define    MAX(a, b)   ((a) > (b) ? (a) : (b))
  64. #define    MIN(a, b)   ((a) < (b) ? (a) : (b))
  65. #define    XSWAP(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
  66. #define SWAP(a, b)  {register int xxx = a; a = b; b = xxx;}
  67. #define    XOR(a, b)   ( ((a) ? 1 : 0) ^ ((b) ? 1 : 0) )
  68.  
  69. /* case macros */
  70. #define    ISDIGIT         '0': case '1': case '2': case '3': case '4': case '5': \
  71.       case '6': case '7': case '8': case '9'
  72. #define    ISUPPER         'A': case 'B': case 'C': case 'D': case 'E': case 'F': \
  73.       case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': \
  74.       case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': \
  75.       case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z'
  76. #define    ISLOWER         'a': case 'b': case 'c': case 'd': case 'e': case 'f': \
  77.       case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': \
  78.       case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': \
  79.       case 'u': case 'v': case 'w': case 'x': case 'y': case 'z'
  80. #define    ISALPHA        ISUPPER: case ISLOWER
  81. #define    PRINTABLE    ' ': case '!': case '"': case '#': case '$': case '%': \
  82.       case '&': case'\'': case '(': case ')': case '*': case '+': case ',': \
  83.       case '-': case '.': case '/': case ':': case ';': case ISDIGIT: \
  84.       case '<': case '=': case '>': case '?': case '@': case ISUPPER: \
  85.       case '[': case'\\': case ']': case '^': case '_': case '`': \
  86.       case ISLOWER: case '{': case '|': case '}': case '~'
  87.  
  88. /*
  89.  * General prototypes
  90.  */
  91. void ClipClose(void);        /* clip.c */
  92. int  ClipCut(char * string);
  93. long ClipPaste(char * buf, long max);
  94.  
  95. char *itos(long);        /* misc.c */
  96. int lstrncmp(register char * str1, register char * str2, register int len);
  97. void udelay(unsigned long val);
  98.  
  99. extern char MEMORY_ERROR_MSG[];    /* napsaterm.c */
  100. extern BOOLEAN started_from_workbench;
  101.  
  102. int write_to_tty(char * buf, int count);
  103. void amigainit(void);
  104. void amigaquit(void);
  105.  
  106. void vtreport(void);        /* emulate.c */
  107. void vtstyle(int c);
  108. void terminalMode(int num, int private, int on);
  109. int decode_escapes(int c);
  110. void termout(char * text, int count);
  111.  
  112. void waitToEnd(void);        /* wimp.c */
  113. void setnewtitle(void);
  114. void perror(const char *banner);
  115. void herror(const char *banner, const char *error);
  116. void fatalError(const char *s, ...); 
  117.  
  118. /* Added by RKNOP for tek4010.c */
  119. #ifdef TEKTRONICS
  120. extern int tekmode;
  121. extern long tekwinmask;
  122. void set_tekmode(unsigned short);
  123. void vt100_tek(void);
  124. void tek_vt100(void);
  125. void graph_clear(void);
  126. char *tekout(char *,char *);    /* Returns new pointer to where in */
  127.                               /* stream we stopped */
  128. void tekpoll(void);
  129. void closetekwin(void);
  130.  
  131. #define TEK_POINT 0
  132. #define TEK_VECTOR 1
  133. #define TEK_INCR 2
  134. #define TEK_ALPHA 3
  135. #define TEK_GIN 4
  136. #define TEK_BLOCK 5
  137.  
  138. #endif
  139. /* End of RKNOP added */
  140.  
  141. #define DEBUG(x) puts(x)
  142. #endif
  143.